<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.CreateGenBankTitle}"></h:outputText>
        </ui:define>
        <ui:define name="body"> <h:form styleClass="form">
                <p:fieldset  legend="GenBank Details"  >
                    <c:choose >
                        <c:when test="#{projectController.items.size() eq 0}" >
                            <div class="warning">
                                There is no projects to be associate with this GenBank <p:commandLink action="/project/Create" value="create"/> one first
                            </div>
                        </c:when>
                        <c:otherwise>
                            <h:panelGrid columns="2" columnClasses="label,field" styleClass="form_list">
                                <h:outputLabel value="#{bundle.CreateGenBankLabel_version}" for="version" />
                                <p:inputText id="version" value="#{genBankController.current.version}" title="#{bundle.CreateGenBankTitle_version}" required="true" requiredMessage="#{bundle.CreateGenBankTitle_version} is required"/>
                                <h:outputLabel value="#{bundle.CreateGenBankLabel_definition}" for="definition" />
                                <p:inputText id="definition" value="#{genBankController.current.definition}" title="#{bundle.CreateGenBankTitle_definition}" required="true" requiredMessage="#{bundle.CreateGenBankTitle_definition} is required"/>
                                <h:outputLabel value="Associate With" for="prjFk" />
                                <p:selectOneMenu id="prjFk" value="#{genBankController.current.prjFk}" title="#{bundle.CreateGenBankTitle_prjFk}" required="true" requiredMessage="#{bundle.CreateGenBankRequiredMessage_prjFk}">
                                    <f:selectItems var="prj" value="#{projectController.items}" itemLabel="#{prj.prjName}" itemValue="#{prj}" transient="true" />
                                </p:selectOneMenu>
                            </h:panelGrid>
                            <br />
                            <p:commandButton action="#{genBankController.create}" value="#{bundle.CreateGenBankSaveLink}" process="@form" update="@form" >
                                <f:setPropertyActionListener target="#{genBankController.current.createdBy}" value="#{userController.loggedUser}"/>
                            </p:commandButton>
                            <p:commandButton action="#{genBankController.prepareList}" value="Show All" immediate="true"/>
                        </c:otherwise>
                    </c:choose>
                </p:fieldset>
            </h:form>
        </ui:define>
    </ui:composition>

</html>
